mod virtio_blk;

pub use virtio_blk::VirtIOBlock;

use crate::board::BlockDeviceImpl;
use alloc::sync::Arc;
//use easy_fs::BlockDevice;
use crate::fs::block::BlockDevice;
use lazy_static::*;

lazy_static! {
    pub static ref BLOCK_DEVICE: Arc<dyn BlockDevice> = Arc::new(BlockDeviceImpl::new());
}

#[allow(unused)]
pub fn block_device_test() {
    println!("block device test");
    let block_device = BLOCK_DEVICE.clone();
    //let mut write_buffer = [0u8; 512];
    let mut read_buffer = [0u8; 512];
    block_device.read_block(0 as usize, &mut read_buffer);
    println!("{:?}", read_buffer);
    let mut read_buffer = [0u8; 512];
    block_device.read_block(0 as usize, &mut read_buffer);
    println!("{:?}", read_buffer);
    //for i in 0..1 {
    //    for by
    //for i in 0..1 {
    //    for byte in write_buffer.iter_mut() {
    //        *byte = 5 as u8;
    //    }
    //    //println!("{:?}", write_buffer);
    //    block_device.write_block(i as usize, &write_buffer);
    //    println!("w 1");
    //    block_device.read_block(i as usize, &mut read_buffer);
    //    println!("r 1");
    //    //println!("{:?}", read_buffer);
    //    assert_eq!(write_buffer, read_buffer, "buffer not equal");
    //}
    println!(
        "---------------------------------\n
        ---------------------------------------\n
        block device test passed!"
    );
}
